<?php

$template = isset($_GET['template']) ? $_GET['template'] : '';
$link = isset($_GET['link']) ? $_GET['link'] : '';
if (empty($template) || empty($link))
{
	header("HTTP/1.1 301 Moved Permanently");
	header("LOCATION: http://www.maibey.com");
	exit();
}
else
{
	$con = mysql_connect("localhost","love","1234567");
	if (!$con)
	  {
	  die('Could not connect: ' . mysql_error());
	  }
	mysql_select_db("Barn", $con);
	
	$sql = 'SELECT url FROM EbayLinks WHERE `template`="'.$template.'" and link ="'.$link.'"';

	$rs = mysql_query($sql,$con);
	while($row = mysql_fetch_array($rs))
	  {
			header("HTTP/1.1 301 Moved Permanently");
			header("LOCATION: ".$row['url']);
			
			mysql_close($con);
			exit();
	  }
	mysql_close($con);
}
?>